package mercurius.fitness.client.ui.menu.items;

import net.pleso.framework.client.ui.custom.CustomFormWindow;
import net.pleso.framework.client.ui.custom.CustomRBWindow;
import mercurius.fitness.client.Fitness;
import mercurius.fitness.client.locale.Locale;
import mercurius.fitness.client.rb.exercise.ExerciseRB;
import mercurius.fitness.client.rb.exercise.forms.AddExerciseForm;
import mercurius.fitness.client.ui.IFrame;
import mercurius.fitness.client.util.Entry;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.MenuBar;

public class ExerciseMenu extends MenuBar  {

	public ExerciseMenu() {
		super(true);
		
		MenuBar graphsubmenu = new MenuBar(true);
		
		addItem(Locale.constants().exercise(),new Command() {

			public void execute() {
				new CustomRBWindow(new ExerciseRB()).show();
			}
			
		});
		
		addItem(Locale.constants().add_exercise(),new Command() {

			public void execute() {
				new CustomFormWindow(null, new AddExerciseForm()).show();
			}
			
		});
		
		addItem("Graphs",graphsubmenu);
		
		graphsubmenu.addItem("Total Points Graph",new Command() {
			public void execute() {
				showRemoteSWFFrame("Total Points Graph", "viewTotalPointGraph");
			}
		});
		
		graphsubmenu.addItem("Zone Points Graph",new Command() {
			public void execute() {
				showRemoteSWFFrame("Zone Points","viewZonePointsGraph");
			}
		});

		
		/*
		
		addItem(Locale.constants().resistance(),new Command() {

			public void execute() {
				new CustomRBWindow(new ResistanceRB()).show();
			}
			
		});
		
		addItem(Locale.constants().add_resistance(),new Command() {

			public void execute() {
				new CustomFormWindow(null,new AddResistanceForm()).show();
			}
			
		});
		*/
		
	}
	
	private void showRemoteSWFFrame(String caption,String action) {
		Entry[] entries = null;
		if(Fitness.get().getFeedKey().length() > 0) {
			//Entry[] e = {new Entry("module","true"),new Entry("action",action),new Entry("feedkey",Fitness.get().getFeedKey())};
			Entry[] e = {new Entry("fulldisplay","true"),new Entry("action",action),new Entry("feedkey",Fitness.get().getFeedKey())};
			entries = e;
		} else {
		//	Entry[] e = {new Entry("module","true"),new Entry("action",action)};
			Entry[] e = {new Entry("fulldisplay","true"),new Entry("action",action)};
			entries = e;
		}
		
		new IFrame(caption, entries).show();
	}
}